home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / fonts.doc < prev    next >
Text File  |  1996-01-10  |  18KB  |  388 lines

  1.    Copyright (C) 1990, 1995 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17.  
  18. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  19.  
  20. This file, fonts.doc, describes the fonts and font facilities supplied
  21. with Ghostscript.
  22.  
  23. For an overview of Ghostscript and a list of the documentation files, see
  24. README.
  25.  
  26. About Ghostscript fonts
  27. =======================
  28.  
  29. Most of Ghostscript's font files have a .gsf extension.  Each file defines
  30. one (transformable) font specified in outline form.  They are ordinary
  31. Type 1 PostScript outline fonts, and can be given to any PostScript
  32. language interpreter; however, they are not compatible with Adobe Type
  33. Manager or with tools that don't include a full PostScript language
  34. interpreter.  Ghostscript also includes a few files with .pfa extension,
  35. which *are* compatible with Adobe Type Manager.
  36.  
  37. The other font-related file that Ghostscript needs for proper operation is
  38. a file called Fontmap.  This file maps font names (such as /Times-Roman)
  39. to font file names (such as ptmr.gsf).
  40.  
  41. Most of the fonts supplied with Ghostscript are based on various public
  42. domain bitmap fonts, primarily the ones supplied with the X11 distribution
  43. from MIT, and on the public domain Hershey fonts.  The fonts are
  44. distributed in the file `ghostscript-N.NNfonts.tar.Z'.  The bitmap-derived
  45. fonts include the usual Helvetica, Times-Roman, and so on; see the file
  46. `Fontmap' for the complete list, in the usual roman, italic, bold, and
  47. bold italic styles (for the most part).  The Hershey fonts, on the other
  48. hand, are quite different from traditional ones; the file `hershey.doc'
  49. describes them in more detail.
  50.  
  51. The file gs_fonts.ps, which is loaded as part of Ghostscript
  52. initialization, arranges to load fonts on demand using the information
  53. from Fontmap.  If you want to preload all of the known fonts, invoke the
  54. procedure
  55.     loadallfonts
  56. This is not done by default, since the fonts occupy about 50K each and there
  57. are a lot of them.
  58.  
  59. Ghostscript fonts are actually ordinary Ghostscript programs: they use the
  60. extension .gsf instead of .ps simply to be informative.  This convention
  61. is only embodied in the Fontmap file: there is no code that knows about
  62. it.
  63.  
  64. If you want to try out the fonts, prfont.ps contains code for printing a
  65. sampler.  Load this program, by including it in the gs command line or by
  66. invoking
  67.     (prfont.ps) run
  68. and then to produce a sampler of a particular font, invoke
  69.     /fontName DoFont
  70. e.g.
  71.     /Times-Roman DoFont
  72.  
  73. About the Kanji fonts
  74. ---------------------
  75.  
  76. Mr. Tetsurou Tanaka of the Department of Engineering, University of Tokyo,
  77. has created a set of free Kanji fonts that is freely available on the
  78. Internet for anonymous FTP from moe.ipl.t.u-tokyo.ac.jp:/Font and is
  79. distributed with Ghostscript.  Anyone can use these fonts as they are or
  80. with some format translation, and redistribute them without reporting.  If
  81. you redistribute them, you must inform the recipient that he can get the
  82. original from the abovementioned FTP site, so that he could get the newest
  83. version later.
  84.  
  85. The fonts include a README file in Japanese.  Here is some English
  86. documentation supplied by Mr. Kiyotaka Sakai, also of the University of
  87. Tokyo.
  88.  
  89.     The following four fonts are different styles of the same characters
  90.     (JISX208). These fonts also needs wadalab-sym.tar.Z in common.
  91.  
  92.     wadalab-mincho-0-8.tar.gz
  93.     wadalab-mincho-0-12.6.tar.gz
  94.     wadalab-gothic-0-13.5.tar.gz
  95.     wadalab-maru-0-8.4.tar.gz
  96.  
  97.     And the following two fonts are the other different styles of the same
  98.     characters(JISX0212).
  99.  
  100.     wadalab-mincho-1-8.tar.gz
  101.     wadalab-maru-1-8.tar.gz
  102.  
  103.     These fonts are postscript(type1) fonts. You can convert them to
  104.     Metafont, Type1(PFA) font, TeX font(for japanese TeX), BDF font,
  105.     Shotaikurabu font by using wftomf.c, wftopfa.c, wftodm.c, bdfmerge.c
  106.     wftovf.c in tools directory.
  107.  
  108. In order to conform to MS-DOS naming restrictions, we have renamed the
  109. original font files as follows:
  110.     Name        Original name
  111.     ----        -------------
  112.     got013-5.taz    wadalab-gothic-0-13.5.tar.gz
  113.     mar08-4.taz    wadalab-maru-0-8.4.tar.gz
  114.     mar18.taz    wadalab-maru-1-8.tar.gz
  115.     min012-6.taz    wadalab-mincho-0-12.6.tar.gz
  116.     min08-4.taz    wadalab-mincho-0-8.4.tar.gz
  117.     min18.taz    wadalab-mincho-1-8.tar.gz
  118.     sym-4.taz    wadalab-sym.4.tar.gz
  119.  
  120. Platform fonts
  121. ==============
  122.  
  123. Starting with release 2.6.1, Ghostscript uses whatever font technology is
  124. provided by the system on which it runs, by using the system's API for
  125. displaying text.  On MS Windows this may be TrueType, or it may be ATM;
  126. Ghostscript neither knows nor cares.  Note that Ghostscript does not
  127. contain a TrueType rasterizer, so it cannot read disk files containing
  128. TrueType fonts; don't put the names of TrueType font files (.FON or .TTF
  129. or .PTF whatever they are called) in Ghostscript's Fontmap.
  130.  
  131. The PostScript language specifies that fonts are data structures with
  132. particular contents (e.g., they include a bounding box for the font, an
  133. Encoding vector for specifying the character set, etc.), and it is fairly
  134. common for PostScript files to make use of this fact; also, characters can
  135. be used as clipping regions, and can be arbitrarily rotated, skewed,
  136. expanded/condensed, etc. algorithmically.  Most of this information is
  137. available in one form or another from the underlying graphics system, but
  138. one crucial piece is not: the actual scalable outlines of the characters,
  139. which Ghostscript needs in order to implement clipping with character
  140. shapes and to implement arbitrarily transformed characters.  Consequently,
  141.  
  142.     Ghostscript needs the scalable outlines of any font mentioned
  143.     in a document, and will load them from the disk (.PFA, .PFB, or
  144.     .GSF file) in the usual way, even if it uses the platform's font
  145.     machinery for displaying the characters.
  146.  
  147. To make matters worse, platforms use different names for their standard
  148. fonts.  For example, the Times Roman font, for which PostScript files use
  149. the name "Times-Roman", may be known as "Times-Roman", "Times Roman", "Tms
  150. Rmn", "Times New Roman", or "TimesNewRoman".  The name may even be
  151. completely different: the usual Helvetica-equivalent TrueType font is
  152. called "Arial".  Now, it is possible to cope with this situation by
  153. introducing aliases in Fontmap, but there are two reasons why the
  154. current Ghostscript release does not do this:
  155.  
  156.     1) Naming in different systems is so unstandardized that there
  157. does not seem to be a small set of alternative names that is likely to
  158. cover most of the situations.  All 5 of the above names for Times Roman
  159. have been seen in Windows and OS/2 environments, depending on system
  160. version, TrueType vs.  ATM, and other unknown factors.
  161.  
  162.     2) Each alias takes up a substantial amount of space (several
  163. hundred bytes) at run time.  If each of the standard 35 fonts has 3
  164. additional aliases, this might amount to 50K of wasted space.  This is a
  165. lot on a PC, although running under Windows in enhanced mode, it might not
  166. be a problem.
  167.  
  168. If you don't seem to be getting nice characters on the screen under MS
  169. Windows, you can try adding aliases to the Fontmap, according to the
  170. documentation found there.
  171.  
  172. Adding your own fonts
  173. =====================
  174.  
  175. Ghostscript can use any Type 1 or Type 3 font that is acceptable to other
  176. PostScript language interpreters.  Ghostscript also provides a way to
  177. construct a Type 1 font from a bitmap font in BDF format, which is a
  178. popular format in the Unix world.
  179.  
  180. If you want to add fonts of your own, you must edit Fontmap to include an
  181. entry for your new font at the end.  The format for entries is documented
  182. in the Fontmap file.  Since later entries in Fontmap override earlier
  183. entries, any fonts you add will supersede the corresponding fonts supplied
  184. with Ghostscript.
  185.  
  186. In the PC world, Type 1 fonts are customarily given names ending in .PFA
  187. or .PFB.  Ghostscript can use these directly; you just need to make the
  188. entry in Fontmap.  If you are going to use a commercial Type 1 font (such
  189. as fonts obtained in conjunction with Adobe Type Manager) with
  190. Ghostscript, please read carefully the license that accompanies the font;
  191. Aladdin Enterprises takes no responsibility for any possible violations of
  192. such licenses.
  193.  
  194. Converting BDF fonts
  195. --------------------
  196.  
  197. If you want to convert a BDF file to a scalable outline, use the program
  198. bdftops.ps (and invoking shell script bdftops.bat or bdftops).  Run the
  199. shell command
  200.     bdftops <BDF_file_name> [<AFM_file1_name> ...] <your_gsf_file_name>
  201.       <font_name> <uniqueID> [<XUID>] [<encoding_name>]
  202. e.g.,
  203.     bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf
  204.       ZapfDingbats 4100000 1000000.1.41
  205. (Obviously, you would enter this all on one line; the example is split so
  206. it will fit on the page.)  Then make an entry for the .gsf file in Fontmap
  207. as described above.  You may find it helpful to read, and to add an entry
  208. to, the fonts.mak file, which is a makefile for converting the standard
  209. Ghostscript fonts.
  210.  
  211. For developers only
  212. ===================
  213.  
  214. The rest of this document is very unlikely to be of value to ordinary
  215. users.
  216.  
  217. Contents of fonts
  218. -----------------
  219.  
  220. A Ghostscript font is a dictionary with a standard set of keys as follows.
  221. The keys marked with a * have the same meanings as in P*stScr*pt fonts;
  222. those marked with # have the same meanings as in Adobe Type 1 fonts.  Note
  223. that FontName is required, and StrokeWidth is required for all stroked or
  224. outlined fonts.
  225.  
  226. *    - FontMatrix <array>: the transformation from character
  227.       coordinates to user coordinates.
  228.  
  229. *    - FontType <integer>: the type of the font, either 1 or 3.
  230.  
  231. *    - FontBBox <array>: the bounding box of the font.
  232.  
  233. *    - Encoding <array>: the map from character codes to character
  234.       names.
  235.  
  236. *    - FontName <name>: the name of the font.
  237.  
  238. *    - PaintType <integer>: an indication of how to interpret the
  239.       character description from CharInfo.
  240.  
  241. *    - StrokeWidth <number>: the stroke width for outline fonts.
  242.  
  243. *    - FontInfo <dictionary>: additional information about the font
  244.       (optional, not used by the standard Ghostscript software).
  245.  
  246. *    - UniqueID <integer>: a unique number identifying the font.
  247.  
  248. *    - BuildChar <procedure>: the procedure for showing a character
  249.       (not required in type 1 fonts).
  250.  
  251. #    - CharStrings <dictionary>: the map from character names to character
  252.       descriptions (relevant only in type 1 fonts).
  253.  
  254. #    - Private <dictionary>: additional information used by the
  255.       algorithms for rendering outlines fonts (relevant only in type 1
  256.       fonts).
  257.  
  258. The format of values in the CharStrings and Private dictionaries are
  259. described in the Adobe Type 1 Font Format book.
  260.  
  261. Precompiling fonts
  262. ------------------
  263.  
  264. You can compile any Type 1 font into C and link it into the Ghostscript
  265. executable.  (Type 1 fonts include any font whose name ends with .pfa or
  266. .pfb, and it also includes all the Ghostscript .gsf fonts except for the
  267. Hershey fonts.)  This doesn't have any effect on rendering speed, but it
  268. eliminates the time for loading the font dynamically, which may make a big
  269. difference in total rendering time, especially for multi-page documents.
  270. (Because of RAM and compiler limitations, you should only use compiled
  271. fonts on MS-DOS systems if you are using a 32-bit compiler such as Watcom
  272. C/386 or djgpp; you will run out of memory if you use compiled fonts with
  273. the Borland compiler.)  Fonts that have been precompiled and linked in
  274. this way do not need to appear in the Fontmap, although if they do appear
  275. there, no harm is done.
  276.  
  277. The utility for precompiling fonts is called font2c.  Note that font2c is
  278. a PostScript language program, so you must have Ghostscript already
  279. running to be able to run font2c; you must also have entries in the
  280. Fontmap for the fonts you want to compile.  For example, to precompile
  281. the Times-Italic font,
  282.     font2c Times-Italic ptmri.c
  283. where the first argument is the font name and the second is the name of
  284. the .c file.  You can use any file name you want, as long as it ends in
  285. .c.  It doesn't have to be limited to 8 characters, unless your operating
  286. system requires this.  We suggest that you use names xxxx.c, where
  287. xxxx.gsf or xxxx.pfa is the name of the font file in the Fontmap file,
  288. just so you don't have to keep track of another set of names.  (If you are
  289. running on a VMS platform, or another platform where the C compiler has a
  290. limit on the length of identifiers, you must do something slightly more
  291. complicated; see the section 'Platforms with identifier length limits'
  292. below.  Also, on VMS, you must put quotes "" around the font name so that
  293. the VMS command processor doesn't convert the name to lower case.)
  294.  
  295. For VMS environments, see the directions in the file make.doc, and ignore
  296. the rest of this section.
  297.  
  298. Note that ncrr.c, ptmr.c, etc. are not supplied with the Ghostscript
  299. fileset, since they are quite large and can easily be recreated using the
  300. font2c program as described above.  There is a makefile called cfonts.mak
  301. that will run font2c on all the fonts supplied with Ghostscript.  Invoke it
  302. with
  303.     make -f cfonts.mak
  304. On some systems, you may have to omit the space following the -f, i.e.,
  305.     make -fcfonts.mak
  306.  
  307. Besides running font2c, you must arrange things so that the fonts will be
  308. compiled, and linked into the executable.  To do this, add the compiled
  309. fonts "feature" to your platform-specific makefile.  On MS-DOS systems, you
  310. edit tc.mak, bc.mak, bcwin.mak, msc.mak, or watc.mak; on Unix systems, you
  311. edit ansihead.mak, cc-head.mak, or gcc-head.mak, and then execute tar_cat.
  312. Find the definition of the FEATURE_DEVS macro in the makefile, e.g.,
  313.     FEATURE_DEVS=level2.dev pdf.dev
  314. and add ccfonts.dev, e.g.,
  315.     FEATURE_DEVS=level2.dev pdf.dev ccfonts.dev
  316.  
  317. Next, you must add the specific fonts to the generic makefile.  On MS-DOS
  318. systems, you edit gs.mak; on Unix systems, you edit makefile.  The makefile
  319. already has rules for the standard 35 fonts supplied with Ghostscript.
  320. Find the line in the relevant makefile that says
  321.     #ccfonts1_=<something>
  322. Remove the # mark from this line, and from all the following lines down to
  323. and including the one that says
  324.     #ccfonts9=<something>
  325. This is all you need to do for the standard fonts.  The next couple of
  326. paragraphs describe how to compile in other fonts, such as the Utopia or
  327. Kana fonts or your own fonts.
  328.  
  329. Suppose you want to compile the Kana fonts into the executable.  First,
  330. pick one of ccfonts10 through 15 as the place you will do this, say
  331. ccfonts10.  Add your compiled font file names, e.g.,
  332.     ccfonts10_=fhirw.$(OBJ)
  333. If the line gets too long, use another line of the same form, e.g.,
  334.     ccfonts11_=fkarw.$(OBJ)
  335. Just below this, you will find a line that says
  336.     ccfonts10_=
  337. Add your own fonts to the end of this line, e.g.,
  338.     ccfonts10=Calligraphic_Hiragana
  339. Notice that you must replace `-' by `_' in the font name.  Again, if
  340. the line gets too long, add another line of the same form, e.g.,
  341.     ccfonts10=Calligraphic_Hiragana
  342.     ccfonts11=Calligraphic_Katakana
  343.  
  344. After all the lines of this form, add a pair of lines to compile each font,
  345. separating these entries from the ccfonts* lines and from each other by a
  346. blank line.  In our example:
  347.  
  348.     fhirw.$(OBJ): fhirw.c $(CCFONT)
  349.         $(CCCF) fhirw.c
  350.  
  351.     fkarw.$(OBJ): fkarw.c $(CCFONT)
  352.         $(CCCF) fkarw.c
  353.  
  354. Finally, run `make'.  The executable will now include the fonts you added.
  355. They will be present in FontDirectory when Ghostscript starts up.
  356.  
  357. Precompiling fonts on platforms with identifier length limits
  358. -------------------------------------------------------------
  359.  
  360. On some platforms, the C compiler and/or linker have a limit on the number
  361. of significant characters in an identifier.  On such platforms, you must
  362. do a little extra work.
  363.  
  364. Let N be the maximum number of significant characters in an identifier
  365. (typically 31).  For each font whose name is longer than N-5 characters,
  366. pick an arbitrary identifier that we will call the "short name".  This can
  367. be any string you want, as long as it contains only letters, digits, and
  368. underscores; is no longer than N-5 characters; and is not the same as any
  369. other font name or short name.  A good choice for this would be to use the
  370. name of the C file.  (There is no harm in doing this for fonts with names
  371. shorter than N-5 characters, it's just not necessary.)
  372.  
  373. You must do two different things for fonts that require a short name.
  374. First, you must supply the short name as a third argument to the font2c
  375. program.  For example, to compile NewCenturySchlbk-BoldItalic using the
  376. short name "pncbi",
  377.     font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi
  378. Then when you add the font to the gsaddmod line in the makefile, use the
  379. short name, not the actual font name, e.g.,
  380.     ccfonts2=pncbi
  381. instead of
  382.     ccfonts2=NewCenturySchlbk_BoldItalic
  383. Everything else is as described above.
  384.  
  385. This procedure doesn't change the name of the font in the Fontmap, or as
  386. seen from within Ghostscript; it's just a workaround for a limitation of
  387. some older compilers.
  388.